package com.xiaolin.mybatis.utils;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

/**
 * @ClassName SqlSessionFactoryUtils
 * @Description TODO
 * @Detail detail
 * @Author MyPC
 * @Date 2020/11/7
 * @Version 1.0
 */
public class SqlSessionFactoryUtils {
    public static SqlSessionFactory sqlSessionFactory(String resource){
        InputStream resourceAsStream = null;
        try {
            resourceAsStream = Resources.getResourceAsStream(resource);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return new SqlSessionFactoryBuilder().build(resourceAsStream);
    }
}
